﻿using FreeSql;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;
using Volo.Abp;
using Volo.Abp.Uow;
using Volo.Abp.Threading;
using Volo.Abp.Domain.Services;

namespace Leo.Core.AbpFreeSql
{
    public abstract class FreeSqlBasicRepository : DomainService
    {
        protected IFreeSql FreeSql => LazyServiceProvider.LazyGetRequiredService<IFreeSql>();

        private ICancellationTokenProvider CancellationTokenProvider =>
            LazyServiceProvider.LazyGetService<ICancellationTokenProvider>(NullCancellationTokenProvider.Instance);

        protected virtual CancellationToken GetCancellationToken(CancellationToken preferredValue = default)
        {
            return CancellationTokenProvider.FallbackToProvider(preferredValue);
        }
    }
}
